module flow_led #(
    parameter LED_CHANNEL = 8,				//LED数量
    parameter COUNT_PERIOD = 25_000_000		//计数器最大周期，决定LED多久变化依次
)
(
	input sys_clk,
    input sys_rst_n,
    output [LED_CHANNEL-1:0] led
);

//周期计数器
reg [31:0] count;
//控制点亮那个LED
reg [7:0] led_flag;

//进行周期计数
always @(posedge sys_clk) begin
	if(!sys_rst_n)
		count <= 32'd0;
	else if(count < (COUNT_PERIOD - 1))
    	count <= count + 32'd1;
	else
    	count <= 32'd0;
end

//LED流水计数，控制点亮那个LED
always @(posedge sys_clk) begin
	if(!sys_rst_n)
    	led_flag <= 8'd0;
	else if(count == (COUNT_PERIOD - 1)) begin
    	if(led_flag < (LED_CHANNEL - 1))
        	led_flag <= led_flag + 8'd1;
    	else
        	led_flag <= 8'd0;
    end
end

//根据led_flag计数点亮对应LED
assign led = (sys_rst_n == 1'b1) ? (32'h1 << led_flag) : 32'h0;

endmodule
